class Cat:
	def __init__(self, name):
		self.name = name
		print('cat name is -->', name)

	def __enter__(self):
		print('this is enter method')
		return self.name

	def __exit__(self, exc_type, exc_val, exc_tb):
		if exc_type is None:
			print('no exception')
		else:
			print('encounter exception, exception is -->', exc_type)
			return False


with Cat('tom') as tom:
	print(tom)
	print('with block has no exception')

with Cat('tony') as tony:
	print(tony)
	raise Exception
